//
//  NGHomeListClassifyCollectionViewCell.swift
//  NingguoForum
//
//  Created by zhengsw on 2022/11/9.
//  Copyright © 2022 zhengsw. All rights reserved.
//

import UIKit
import SnapKit
import Kingfisher

class NGHomeListClassifyCollectionViewCell: UICollectionViewCell {
    let titleLabel: UILabel!
    let iconImg: UIImageView!
    override init(frame: CGRect) {
        
        titleLabel = UILabel()
        iconImg = UIImageView()
        
        super.init(frame: frame)
        
        titleLabel.text = "--";
        titleLabel.font = UIFont.systemFont(ofSize: 10)
        titleLabel.textColor = RGB_COLOR(r: 100, g: 100, b: 100)
        contentView.addSubview(titleLabel)
        
        iconImg.image = UIImage.init()
        iconImg.layer.masksToBounds = true
        iconImg.contentMode = .scaleAspectFill
        contentView.addSubview(iconImg)
        
        iconImg.snp.makeConstraints { (make) ->Void in
            make.centerX.equalTo(contentView.snp.centerX)
            make.top.equalToSuperview().offset(5)
            make.size.equalTo(CGSize(width: 30, height: 30))
        }
        
        titleLabel.snp.makeConstraints { (make) ->Void  in
            make.top.equalTo(iconImg.snp_bottom).offset(5)
            make.centerX.equalTo(contentView.snp_centerX)
        }

    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    func setModel(model: HomeClassifyModel){
        titleLabel.text = model.title
        iconImg.kf.setImage(with: URL(string: model.pic));
    }
    
}
